bitkeeper revision 1.1075 (40f3d929OFHwDCndxHCAhHnmUAclPg)
authormjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Tue, 13 Jul 2004 12:44:25 +0000 (12:44 +0000)
committermjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Tue, 13 Jul 2004 12:44:25 +0000 (12:44 +0000)
Improve error trapping in xm.
Allow nfs_server to override dummy addr.

tools/python/xen/xend/Args.py
tools/python/xen/xend/XendClient.py
tools/python/xen/xm/create.py
tools/python/xen/xm/main.py

index f70000a9d58c28fd3eaf0a32a73cab9893cc30e2..8920a65d1bf8efacdaf53ec759d5939e3a1a2688 100644 (file)
@@ -107,11 +107,11 @@ class Args:
 
     def call_with_args(self, fn, args, xargs=None):
         (params, keys) = self.get_args(args, xargs=xargs)
-        fn(*params, **keys)
+        return fn(*params, **keys)
 
     def call_with_form_args(self, fn, fargs, xargs=None):
         (params, keys) = self.get_form_args(fargs, xargs=xargs)
-        fn(*params, **keys)
+        return fn(*params, **keys)
 
 class ArgFn(Args):
     """Represent a remote HTTP operation as a function.
index add488023b92bf5e53947d5d77b676d1996ecbd4..a6077ab20d8155641a6513d37b6f34ebda28dc38 100644 (file)
@@ -136,7 +136,7 @@ def xend_request(url, method, data=None):
     #if isinstance(val, types.ListType) and sxp.name(val) == 'val':
     #    val = val[1]
     if isinstance(val, types.ListType) and sxp.name(val) == 'err':
-        raise RuntimeError(val[1])
+        raise XendError(val[1])
     if DEBUG: print '**val='; sxp.show(val); print
     return val
 
index 1e6b7dce4ad290244d2bf61e07b71d71d839b41c..ea1d1b020dd13452dd88688916fabbd0bff02b18 100644 (file)
@@ -347,8 +347,9 @@ def preprocess_ip(opts, vals):
     setip = (vals.hostname or vals.netmask
              or vals.gateway or vals.dhcp or vals.interface)
     if not setip: return
+    dummy_nfs_server = '1.2.3.4'
     ip = (vals.ip
-          + ':' + '1.2.3.4'
+          + ':' + (vals.nfs_server or dummy_nfs_server)
           + ':' + vals.gateway
           + ':' + vals.netmask
           + ':' + vals.hostname
@@ -357,11 +358,9 @@ def preprocess_ip(opts, vals):
     vals.cmdline_ip = ip
 
 def preprocess_nfs(opts, vals):
-    if (vals.nfs_root or vals.nfs_server):
-        if (not vals.nfs_root) or (not vals.nfs_server):
-            opts.err('Must set nfs root and nfs server')
-    else:
-        return
+    if not vals.nfs_root: return
+    if not vals.nfs_server:
+        opts.err('Must set nfs root and nfs server')
     nfs = 'nfsroot=' + vals.nfs_server + ':' + vals.nfs_root
     vals.extra = nfs + ' ' + vals.extra
     
index d8ac0d43e6f37d6a7d7262ea083491face728335..e624447955745704cbcbf518af02a566b923b041 100644 (file)
@@ -9,7 +9,7 @@ import socket
 
 from xen.xend import PrettyPrint
 from xen.xend import sxp
-from xen.xend.XendClient import server
+from xen.xend.XendClient import XendError, server
 from xen.xend.XendClient import main as xend_client_main
 from xen.xm import create, shutdown
 
@@ -72,6 +72,8 @@ class Xm:
         except socket.error, ex:
             print >>sys.stderr, ex
             self.err("Error connecting to xend, is xend running?")
+        except XendError, ex:
+            self.err(str(ex))
 
     def main_call(self, args):
         """Main entry point. Dispatches to the progs.